#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e6 + 5;

int n, c, m;
int a[N];
struct Node {
  int l, r, id;
  bool operator<(Node x) const { return r < x.r; }
} b[N];
int mn[N], mx[N];
int ans[N];
int bit[N];
int lowbit(int x) { return x & -x; }
void update(int x, int d) {
  for (int i = x; i <= n; i += lowbit(i)) bit[i] += d;
}
int query(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= lowbit(i)) sum += bit[i];
  return sum;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> c >> m;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, m) {
    cin >> b[i].l >> b[i].r;
    b[i].id = i;
  }
  sort(b + 1, b + m + 1);
  int pos = 1;
  rep(i, 1, m) {
    while (pos <= b[i].r) {
      int x = a[pos];
      if (mn[x]) update(mn[x], -1);
      mn[x] = mx[x];
      mx[x] = pos;
      if (mn[x]) update(mn[x], 1);
      pos++;
    }
    ans[b[i].id] = query(b[i].r) - query(b[i].l - 1);
  }
  rep(i, 1, m) cout << ans[i] << endl;
  return 0;
}